package com.zlzxm.shoesmarket.viewmodel;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.zlzxm.shoesmarket.util.RxAndroidHelp;
import com.zlzxm.shoesmarket.view.adapter.ADCalculateSize;
import com.zlzxm.shoesmarket.view.adapter.entity.EntityCalculatePay;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;

/**
 * CREATE BY zlzxm ON 4/26/21
 */
public class VMCalculateOwn extends ViewModel {

    private MutableLiveData<List<EntityCalculatePay>> livePay = new MutableLiveData<>();


    public MutableLiveData<List<EntityCalculatePay>> getLivePay() {
        return livePay;
    }

    public void requestSize(){


        Observable.timer(1, TimeUnit.SECONDS)
                .compose(RxAndroidHelp.turn())
                .subscribe(new Observer<Long>() {
                    @Override
                    public void onSubscribe(@NonNull Disposable d) {

                    }

                    @Override
                    public void onNext(@NonNull Long aLong) {

                    }

                    @Override
                    public void onError(@NonNull Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                        livePay.setValue(createTestDataSize());
                    }
                });

    }

    private List<EntityCalculatePay> createTestDataSize(){


        List<EntityCalculatePay> list = new ArrayList<>();

        for (int i = 0; i < 10; i++) {


            EntityCalculatePay entityCalculatePay = new EntityCalculatePay();
            entityCalculatePay.setTitle("xx费");
            entityCalculatePay.setPay("¥199");


            list.add(entityCalculatePay);
        }



        return list;



    }

}
